import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

public class TestDemo {
    public static void main(String[] args) {
        String str="abcdef";
        StringBuilder sb=new StringBuilder();
        sb.append(str);
        for (int i = 0; i < 10; i++) {
            sb.append(i);
        }
        str=sb.toString();
        System.out.println(str);
    }
    public static void main15(String[] args) {
        String str="";
        String ret=str.concat("java");
        System.out.println(ret);
        System.out.println(str.length());
        int[] array={1,2,3,4,5};
        System.out.println(array.length);
        System.out.println(str.isEmpty());
    }
    public static void main14(String[] args) {
        String str="abcdefBFGH123刘";
        String ret=str.toUpperCase();
        System.out.println(ret);
    }
    public static void main13(String[] args) {
        String str="     abc   defgh         ";
        String ret=str.trim();
        System.out.print(ret);
        System.out.println("==========");
    }
    public static void main12(String[] args) {
        String str="abcdefgh";
        String sub=str.substring(2,4);
        System.out.println(sub);
    }
    public static void main11(String[] args) {
        String str="JAVA30 12&21#hello";
        String[]strings=str.split(" |&|#");
         for (String s:strings){
            System.out.println(s);
        }
    }
    public static void main10(String[] args) {
        String str="192.168.1.1";
        String[]result=str.split("\\.");
        for (String s:result){
            System.out.println(s);
        }
        System.out.println("===========");
        String str2="192\\168\\1\\1";
        String[]result2=str2.split("\\\\");
        for (String s:result2){
            System.out.println(s);
        }
    }
    public static void main9(String[] args) {
        String str="name=zhangsan&age=19";
        String[]strings=str.split("&");
        for (String s:strings){
            String[]ss=s.split("=");
            for (String tmp:ss){
                System.out.println(tmp);
            }

        }
    }
    public static void main8(String[] args) {
        String str="name=zhangsan&age=19";
        String[]strings=str.split("&");
        for (String s:strings){
            System.out.println(s);
        }
    }
    public static void main7(String[] args) {
         String str="ababcabcdabcde";
         String ret=str.replace("a","g");
         String ret1=str.replaceFirst("ab","pp");
        System.out.println(ret);
        System.out.println(ret1);
    }
    public static void main6(String[] args) {
        String str1="Abc";
        String str2="abc";
        int ret=str1.compareTo(str2);
        System.out.println(ret);
        System.out.println(str1.equalsIgnoreCase(str2));
    }
    public static void main5(String[] args) {
        String str="ababcabcd";
        String tmp="abc";
        boolean flg=str.contains(tmp);
        System.out.println(flg);
        System.out.println("===========");
        int index=str.indexOf(tmp);
        System.out.println(index);
        System.out.println(str.lastIndexOf(tmp));
        System.out.println(str.startsWith("c"));
        System.out.println(str.endsWith("cde"));
    }
    public static void main4(String[] args) {
        String str1="hello";
        String str2="abcdef";
        System.out.println(str1.equals(str2));
    }
    public static void main3(String[] args) throws UnsupportedEncodingException {
        byte[]bytes={97,98,99,100};
        String str=new String(bytes,1,3);
        System.out.println(str);
        System.out.println("===============");
        String str2="乐乐";
        byte[]bytes1=str2.getBytes("GBK");
        System.out.println(Arrays.toString(bytes1));
    }
    public static boolean isNumberChar(String s){
        for (int i = 0; i < s.length(); i++) {
            char c=s.charAt(i);
            //判断某个字符是不是数字
            boolean flg=Character.isDigit(c);
            if (flg==false){
                return false;
            }
              if(c<'0'||c>'9'){
                  return false;
              }
        }
        return  true;
    }
    public static void main2(String[] args) {
        String str="1234567";
        System.out.println(isNumberChar(str));
    }
    public static void main1(String[] args) {
        char[]val={'a','b','c','d','e'};
        String str=new String(val,1,3);
        System.out.println(str);
        System.out.println("============");
        String str2="hello";
        char ch=str2.charAt(2);
        System.out.println(ch);
       char[]chars= str2.toCharArray();//把str2指向的字符串对象变成字符数组
        System.out.println(Arrays.toString(chars));
    }
}































